package day7;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @author oldliu
 * @since 1.0
 */
public class ClsTest {
    public static void main(String[] args) throws ClassNotFoundException {
        Class c1 = String.class;
        Class c0 = int.class;
        String str = "java";
        Class c2 = str.getClass();
        Class c3 = Class.forName("java.lang.String");
        System.out.println(c1 == c2);
        System.out.println(c3 == c2);
        //获得String的内部信息
        System.out.println("父类：" + c1.getSuperclass().getName());
        System.out.println("包名：" + c1.getPackage().getName());
        //实现的接口
        Class[] interfaces = c1.getInterfaces();
        //属性
        Field[] fields = c1.getDeclaredFields();
        //方法：
        Method[] methods = c1.getDeclaredMethods();
        //构造方法
        Constructor[] crs = c1.getDeclaredConstructors();

    }
}
